#include <iostream>
#include <memory>
#include <string>

#include "TcpServer.hpp"
#include "CommandExcute.hpp"
const static string filepath="./SafeCmd.txt";
using namespace std;

void Usage(const string proc)
{
    cout << "Usage:\n\t" << proc<<" local_port"<<endl;
}

//./tcpserver 8888
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        Usage(argv[0]);
        exit(USAGE_ERROR);
    }
    EnableScreen();

    Command cmd(filepath);
    uint16_t port=stoi(argv[1]);
    unique_ptr<TcpServer> tsvr(new TcpServer(port,std::bind(&Command::Excute,&cmd,placeholders::_1)));

    //初始化服务器
    tsvr->InitServer();

    //启动服务器
    tsvr->Start();

    return 0;
}